package org.yinweichen.llm_dataset_backend.repository;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.yinweichen.llm_dataset_backend.entity.Points;
import java.util.List;

public interface PointsRepository extends JpaRepository<Points, Long> {
    @Query("SELECT p FROM Points p WHERE p.answer.questionId = :answerId AND p.answer.version = :version AND p.active = true")
    List<Points> findByAnswerIdAndActiveTrue(@Param("answerId") Long answerId, @Param("version")String version);

    @Modifying
    @Query("UPDATE Points p SET p.value = :value WHERE p.id = :id")
    int updateValue(@Param("id") Long id, @Param("value") int value);

    @Modifying
    @Query("UPDATE Points p SET p.keyword = :keyword WHERE p.id = :id")
    int updateKeyword(@Param("id") Long id, @Param("keyword") String keyword);
}
